

/*
 * @Author: silence silence9685@163.com
 * @Date: 2023-07-20 19:08:36
 * @LastEditors: silence silence9685@163.com
 * @LastEditTime: 2023-07-27 09:48:38
 * @FilePath: \ems_neutral_app\lib\pages\Login\ForgetPwdSubmitPage.dart
 * @Description: 忘记密码-提交页
 */
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:sil_base_widget_package/sil_base_widget_package.dart';

import '../../base/SilScaffold.dart';
import '../../common/Method/CommonMethod.dart';
import '../../common/widgets/cubitWidget/InputView.dart';
import '../../common/widgets/cubitWidget/SubmitBtn.dart';
import '../../utils/router/ARouter.dart';
import '../Mine/Language/SilLocalizations/SilLocalizations.dart';
import 'Controller/LoginController.dart';
import 'LoginGuidPage.dart';
import 'View/LoginRegisterItem.dart';

class ForgetPwdSubmitPage extends StatefulWidget {
  final String? phone;
  final String? email;
  final String? code;
  const ForgetPwdSubmitPage({this.phone,this.email,this.code,super.key});

  @override
  State<ForgetPwdSubmitPage> createState() => _ForgetPwdSubmitPageState();
}

class _ForgetPwdSubmitPageState extends State<ForgetPwdSubmitPage> {
  String? _password;
  String? _confirmPassword;
  LoginController _loginController = Get.put(LoginController());

  @override
  Widget build(BuildContext context) {
       return SilScaffold(
      sideMargin: 40.w,
      title: LangOf(context)?.resetMM?.reset_pwd,
      body: mainWidget(),
    );
  }

  mainWidget() {
    return Container(
        child: ListView(
      padding: EdgeInsets.symmetric(vertical: 40.w),
      children: [

        LoginRegisterItem(
          imgPath: 'imgs/login/login_zh.png',
          hintText: LangOf(context)?.register?.passwordPlaceholder,
          inputViewType: InputViewType.InputViewTypePassword,
          onValid: (p0, p1) {
            _password = p1;
          },
        ),
        LoginRegisterItem(
          imgPath: 'imgs/login/login_zh.png',
          hintText: LangOf(context)?.register?.passwordPlaceholder_two,
          inputViewType: InputViewType.InputViewTypePassword,
          onValid: (p0, p1) {
            _confirmPassword = p1;
          },
        ),
        submitBtnWidget(),
      ],
    ));
  }

    submitBtnWidget() {
    return Container(
      alignment: Alignment.center,
      child: SubmitBtn(
        margin: EdgeInsets.only(top: 20.w),
        title: LangOf(context)?.resetMM?.done,
        onTapFunc: () {
          // 隐藏键盘
          globalTextFieldDismiss(context);
          _loginController.updatePassword(context: context,password: _password,confirmPassword: _confirmPassword,code: widget.code,account: widget.phone ?? widget.email,successHandler: (p0) {
            ARoute.gotoPage(context, LoginGuidPage());
          },);
        },
      ),
    );
  }

}